class PdfConvert
  if RUBY_PLATFORM =~ /win32/
    def self.pdf_to_text(pdf_file_name, page_number, txt_file_name)
      `"#{File.join(RAILS_ROOT, "lib", "pdftotext.exe")}" -f #{page_number} -l #{page_number} "#{pdf_file_name}" "#{txt_file_name}"`
    end
  elsif RUBY_PLATFORM =~ /linux/
    def self.pdf_to_text(pdf_file_name, page_number, txt_file_name)
      if page_number.nil?
        raise "illegal page number"
      end
      `pdftotext -f #{page_number} -l #{page_number} "#{pdf_file_name}" "#{txt_file_name}"`
    end
  end
end
